package com.ar4j;

import java.util.Map;

/**
 * Basic API for an active record factory. 
 */
public interface IActiveRecordFactory {

  /**
   * Creates a blank active record of the given domain class.
   */
  <E extends ActiveRecord<E>> E getActiveRecord(Class<E> domainClass);
  
  /**
   * Creates a new active record of the given domain class, using data from the
   * given json wrapper.
   */
  <E extends ActiveRecord<E>> E getActiveRecord(Class<E> domainClass, ActiveRecordJsonWrapper wrapper);
  
  /**
   * Creates a new active record which is a copy (excluding the ID field) of the given prototype
   * active record.
   */
  <E extends ActiveRecord<E>> E getActiveRecord(E prototype);
  
  /**
   * Create a new active record of the given domain class and populate it with the values from
   * the given map. The keys of the map represent property names. The values of the map will
   * be coerced to the required type before being copied into the new active record instance.
   */
  <E extends ActiveRecord<E>> E getActiveRecord(Class<E> domainClass, Map<String, Object> values);
  
}
